import 'package:get/get.dart';

class User {
  String name;
  int age;
  User({required this.name, required this.age});
}

class HomeController extends GetxController {
  var user = User(name: '李', age: 18).obs;

  void updateUserName(String newName) {
    user.update((value) {
      value?.name = newName;
    });
  }

  void incrementAge() {
    // user.update((value) {
    //   if (value != null) value.age++;
    // });
    user.update((value) {
      value?.age++;
    });
  }
}
